//
//  FR_AdministratorAcountViewController.m
//  FaceRecognition
//
//  Created by syun on 17/2/10.
//  Copyright © 2017年 Sylar. All rights reserved.
//

#import "FR_AdministratorAcountViewController.h"
#import "DropTable.h"
#import "ClassTopTableViewCell.h"
#import "AccountListTableViewCell.h"
#import "MyAccountTableViewCell.h"
#import "FR_RankListViewController.h"
@interface FR_AdministratorAcountViewController ()
<DropTableDelgate,UITableViewDelegate,UITableViewDataSource>
{
    UILabel      *_navTitlelabel;
    UIImageView  *_navImageView;
    UIImageView  *navBackView;
    DropTable * drop_table;
    UIButton * leftButton;
    UIButton * rightButton;
    UIImageView * scrollLine;
    
    NSInteger daysdis;
    NSInteger monthdis;
    UILabel * dataLabel;//日统计日期
    
    int isdayAcount;//1代表当前日统计 2 代表当前是月统计
    
    NSString * schoolname;
    NSString * selectedClassId;//当前选中的班级id
    NSString * className;
    
    NSString * selectedDataTime;//当前日
    NSString * selectedMonthTime;//当前月
    
    int pageNum;
    int MpageNum;
    
    long long schoolManage;
    
    UILabel * noDataLabel;
    
    NSString * currentmonth;

}
@property (nonatomic, strong) UITableView * classTable;
@property (nonatomic, strong) NSMutableArray * classnameArr;
@property (nonatomic, strong) NSMutableArray * classidArr;
@property (nonatomic, strong) NSMutableArray * rankArray;
@property (nonatomic, strong) NSMutableArray * dataArray;
@end

@implementation FR_AdministratorAcountViewController

- (UITableView *)classTable
{
    if (_classTable == nil) {
        
        _classTable = [[UITableView alloc]initWithFrame:CGRectMake(0,64, SCREENWIDTH, SCREENHEIGH-64) style:UITableViewStylePlain];
        _classTable.delegate = self;
        _classTable.dataSource = self;
        _classTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_classTable setShowsVerticalScrollIndicator:NO];
    }
    
    return _classTable;
}
- (NSMutableArray *)classnameArr
{
    if (_classnameArr  == nil) {
        
        _classnameArr = [NSMutableArray array];
    }
    
    return _classnameArr;
}

- (NSMutableArray *)classidArr
{
    if (_classidArr == nil) {
        
        _classidArr = [NSMutableArray array];
    }
    
    return _classidArr;
}

- (NSMutableArray *)rankArray
{
    if (_rankArray == nil) {
        
        _rankArray = [NSMutableArray array];
    }
    
    return _rankArray;
}

- (NSMutableArray *)dataArray
{
    if (_dataArray == nil) {
        
        _dataArray = [NSMutableArray array];
    }
    
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    daysdis = 0;
    monthdis = 0;
    pageNum = 1;
    MpageNum = 1;
    isdayAcount = 1;//默认日统计
    schoolManage = [SYAccountTool ShareAccount].account.schoolManage;
    
    [self getCurrentData];// 默认当前日期
    
    [self.view addSubview:self.classTable];
    
    [self requestRankingData];
       // Do any additional setup after loading the view.
}


#pragma mark -DropTableDelegate
- (void)tableViewCellSelected:(NSInteger)index{
    
}

- (void)setupUI {

    schoolname = [SYAccountTool ShareAccount].account.scname;
    self.navBar.navigationItem.title = schoolname;

}
#pragma mark - TableViewSoureData

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
        return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 1;
    }else
    {
        return self.dataArray.count;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        
        return 128;
    }else
    {
        return 44;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        
    if (section == 0) {
        
        return 0;
    }else
    {
        return 131;
    }
    
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    if (section == 0) {
        
        UIView * tBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 10)];
        tBack.backgroundColor = [UIColor colorWithHexString:@"f5f8fa"];
        return tBack;
        
    }else
    {
        UIView * tBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 100)];
        tBack.backgroundColor = [UIColor whiteColor];
        
        UILabel * separateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 10)];
        separateLabel.backgroundColor = [UIColor colorWithHexString:@"f5f8fa"];
        [tBack addSubview:separateLabel];
        
        leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        leftButton.frame =CGRectMake(0, 10, SCREENWIDTH/2, 44);
        leftButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [leftButton setTitle:@"日统计" forState:UIControlStateNormal];
        [leftButton setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
        [leftButton addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [tBack addSubview:leftButton];
        
        rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        rightButton.frame =CGRectMake(SCREENWIDTH/2, 10, SCREENWIDTH/2, 44);
        rightButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [rightButton setTitle:@"月统计" forState:UIControlStateNormal];
        [rightButton setTitleColor:[UIColor colorWithHexString:@"3b3b3b"] forState:UIControlStateNormal];
        [rightButton addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
        [tBack addSubview:rightButton];
        
        if (isdayAcount == 1) {
            
            scrollLine = [[UIImageView alloc]initWithFrame:CGRectMake(0, 52, SCREENWIDTH/2, 2)];
            [leftButton setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
            [rightButton setTitleColor:[UIColor colorWithHexString:@"3b3b3b"] forState:UIControlStateNormal];
        }else
        {
            scrollLine = [[UIImageView alloc]initWithFrame:CGRectMake(SCREENWIDTH/2, 52, SCREENWIDTH/2, 2)];
            [leftButton setTitleColor:[UIColor colorWithHexString:@"3b3b3b"] forState:UIControlStateNormal];
            [rightButton setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
        }

        
        scrollLine.backgroundColor = DEFAULTCOLOR;
        [tBack addSubview:scrollLine];
        
        UILabel * line = [[UILabel alloc]initWithFrame:CGRectMake(0, 53.5, SCREENWIDTH, 0.5)];
        line.backgroundColor = [UIColor colorWithHexString:@"dedede"];
        [tBack addSubview:line];
        
        dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREENWIDTH/2-50, CGRectGetMaxY(line.frame)+10, 80, 20)];
        
        if (isdayAcount == 1) {
            
            dataLabel.text = selectedDataTime;
            
        }else
        {
            dataLabel.text = selectedMonthTime;
        }

        CGSize  size = [dataLabel.text boundingRectWithSize:CGSizeMake(1000, 20)  options:(NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin)   attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:15]} context:nil].size;
        
        
        dataLabel.frame = CGRectMake(SCREENWIDTH/2-size.width/2, CGRectGetMaxY(line.frame)+10, size.width, 20);
        dataLabel.font = [UIFont systemFontOfSize:15];
        dataLabel.textColor = [UIColor colorWithHexString:@"3b3b3b"];
        dataLabel.textAlignment = NSTextAlignmentCenter;
        [tBack addSubview:dataLabel];
        
        UIButton * reduceButton = [UIButton buttonWithType:UIButtonTypeCustom];
        reduceButton.frame = CGRectMake(SCREENWIDTH/2-dataLabel.frame.size.width/2-50, CGRectGetMaxY(line.frame), 50, 40);
        [reduceButton setImageEdgeInsets:UIEdgeInsetsMake(0, 23, 0, 0)];
        [reduceButton setImage:[UIImage imageNamed:@"arrow_left_"] forState:UIControlStateNormal];
        [reduceButton addTarget: self action:@selector(reduceAction:) forControlEvents:UIControlEventTouchUpInside];
        [tBack addSubview:reduceButton];
        
        UIButton * addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        addButton.frame = CGRectMake(SCREENWIDTH/2+dataLabel.frame.size.width/2, CGRectGetMaxY(line.frame), 50, 40);
        [addButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 23)];
        [addButton setImage:[UIImage imageNamed:@"arrow_right_"] forState:UIControlStateNormal];
        [addButton addTarget: self action:@selector(addAction:) forControlEvents:UIControlEventTouchUpInside];
        [tBack addSubview:addButton];
        
        UILabel * line2 = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(reduceButton.frame), SCREENWIDTH, 0.5)];
        line2.backgroundColor = [UIColor colorWithHexString:@"dedede"];
        [tBack addSubview:line2];
        
        UILabel * nameLable = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line2.frame)+12, SCREENWIDTH/2, 16)];
        nameLable.text = @"姓名";
        nameLable.font = [UIFont systemFontOfSize:16];
        nameLable.textColor = [UIColor colorWithHexString:@"3b3b3b"];
        nameLable.textAlignment = NSTextAlignmentCenter;
        [tBack addSubview:nameLable];
        
        UILabel * timeLable = [[UILabel alloc]initWithFrame:CGRectMake(SCREENWIDTH/2, CGRectGetMaxY(line2.frame)+12, SCREENWIDTH/2, 16)];
        timeLable.text = @"时间";
        timeLable.font = [UIFont systemFontOfSize:16];
        timeLable.textColor = [UIColor colorWithHexString:@"3b3b3b"];
        timeLable.textAlignment = NSTextAlignmentCenter;
        [tBack addSubview:timeLable];
        
        return tBack;
    }
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        
        ClassTopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ClassTopCell"];
        if (cell == nil) {
            
            cell = [[ClassTopTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ClassTopCell"];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        NSString * monthStr = [self getCurrentMonthString];
        
        if (monthStr.length > 5 ) {
            
            monthStr = [monthStr substringFromIndex:5];
            
            if (monthStr.length > 1) {
                
                currentmonth = [monthStr substringToIndex:1];
                
                if([currentmonth isEqualToString:@"0"])
                {
                    currentmonth = [monthStr substringFromIndex:1];
                }else
                {
                    currentmonth = monthStr;
                }
            }
        }
        
        cell.markLabel.text = [NSString stringWithFormat:@"%@月勤奋榜",currentmonth];
        [cell setDataForCell:self.rankArray];
        
        [cell.rankButton addTarget:self action:@selector(pushRankListAction:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
        
    }else
    {
        AccountListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccountListcell"];
        
        if (cell == nil) {
            cell = [[AccountListTableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"AccountListcell"];
            
        }
        
        RankModel * model =[self.dataArray objectAtIndex:indexPath.row];
        
        cell.numlab.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row + 1];
        cell.nameLabel.text = model.username;
        
        if (model.jointime.length > 11) {
            
            cell.timeLabel.text = [model.jointime substringFromIndex:11];
        }
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}

- (void)pushRankListAction :(UIButton *)sender
{
    FR_RankListViewController * rankListVC = [[FR_RankListViewController alloc]init];
    rankListVC.CurrentSchoolName = schoolname;
    rankListVC.schoolID = [NSString stringWithFormat:@"%lld",schoolManage];
    rankListVC.flag = 2;
//    rankListVC.rankArr = self.rankArray;
    [self.navigationController pushViewController:rankListVC animated:YES];
}

#pragma ButtonAction

- (void)leftAction :(UIButton *)sender
{
        daysdis = 0;
    
    if (isdayAcount != 1) {
        
        dataLabel.text = [self getCurrentData];
        pageNum = 1;
        [self requstDateRankData];
    }
    isdayAcount = 1;
    [rightButton setTitleColor:[UIColor colorWithHexString:@"3b3b3b"] forState:UIControlStateNormal];
    [leftButton setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
    scrollLine.frame = CGRectMake(0, 52, SCREENWIDTH/2, 2);
    
    
}

- (void)rightAction :(UIButton *)sender
{
    
        monthdis = 0;
    
    if (isdayAcount != 2) {
        
        [self getCurrentMonth];
        MpageNum = 1;
        [self requstMonthRankData];
    }
    
    isdayAcount = 2;
    [leftButton setTitleColor:[UIColor colorWithHexString:@"3b3b3b"] forState:UIControlStateNormal];
    [rightButton setTitleColor:DEFAULTCOLOR forState:UIControlStateNormal];
    scrollLine.frame = CGRectMake(SCREENWIDTH/2, 52, SCREENWIDTH/2, 2);
    
}

- (void)reduceAction :(UIButton *)sender
{
    if (isdayAcount == 1) {
        
        [self getLastData];
        [self requstDateRankData];
    }else
    {
        [self getLastMonth];
        [self requstMonthRankData];
    }
}

- (void)addAction :(UIButton *)sender
{
    if (isdayAcount == 1) {
        
        [self getNextData];
        [self requstDateRankData];
    }else
    {
        [self getnextMonth];
        [self requstMonthRankData];
    }
    
}

- (NSString * )getCurrentData
{
    NSDate *currentDate = [NSDate date];//获取当前时间，日期
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd"];
    NSString *dateString = [dateFormatter stringFromDate:currentDate];
    selectedDataTime = dateString;
    return dateString;
}

- (void)getLastData
{
    daysdis --;
    
    NSDate * nowDate = [NSDate date];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM-dd"];
    
    NSTimeInterval  oneDay = 24*60*60*1;  //1天的长度
    
    NSDate *lastDay;
    
    
    lastDay = [NSDate dateWithTimeInterval:+oneDay*daysdis sinceDate:nowDate];
    
    
    NSString *day = [formater stringFromDate:lastDay];
    
    selectedDataTime = day;
    
    dataLabel.text = day;
}

- (void)getNextData
{
    daysdis ++;
    
    NSDate * nowDate = [NSDate date];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM-dd"];
    
    NSTimeInterval  oneDay = 24*60*60*1;  //1天的长度
    
    NSDate *nextDay = [NSDate dateWithTimeInterval:+oneDay*daysdis sinceDate:nowDate];
    
    NSString *day = [formater stringFromDate:nextDay];
    
    selectedDataTime = day;
    
    dataLabel.text = day;
    
}

- (void)getCurrentMonth
{
    NSCalendar *calender = [NSCalendar currentCalendar];//获取NSCalender单例。
    NSDateComponents *cmp = [calender components:(NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:[NSDate date]]; //设置属性，因为我只需要年和月，这个属性还可以支持时，分，秒。
    NSDate *currentMonDate = [calender dateFromComponents:cmp];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM"];
    
    NSString *month = [formater stringFromDate:currentMonDate];
    
    selectedMonthTime = month;
    
    dataLabel.text = month;
    
}

- (void)getLastMonth
{
    monthdis--;
    NSCalendar *calender = [NSCalendar currentCalendar];//获取NSCalender单例。
    NSDateComponents *cmp = [calender components:(NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:[NSDate date]]; //设置属性，因为我只需要年和月，这个属性还可以支持时，分，秒。
    [cmp setMonth:[cmp month]+monthdis];
    
    NSDate *lastMonDate = [calender dateFromComponents:cmp];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM"];
    
    NSString *month = [formater stringFromDate:lastMonDate];
    
    selectedMonthTime = month;
    
    dataLabel.text = month;
}

- (void)getnextMonth
{
    monthdis++;
    NSCalendar *calender = [NSCalendar currentCalendar];//获取NSCalender单例。
    NSDateComponents *cmp = [calender components:(NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:[NSDate date]]; //设置属性，因为我只需要年和月，这个属性还可以支持时，分，秒。
    [cmp setMonth:[cmp month]+monthdis];
    
    NSDate *nextMonDate = [calender dateFromComponents:cmp];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM"];
    
    NSString *month = [formater stringFromDate:nextMonDate];
    
    selectedMonthTime = month;
    
    dataLabel.text = month;
}

#pragma dataSource

-(void)requestRankingData
{
    
    RequestParam *param = [[RequestParam alloc] init];
    param.classid = @"0";
    param.scid = [NSString stringWithFormat:@"%lld",schoolManage];
    param.datetime = [NSString stringWithFormat:@"%@-01",[self getCurrentMonthString]];
    
    [Utils Java_get:@"api/getMonthCountTop" parameters:param.mj_keyValues success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.rankArray removeAllObjects];
        
        if (array.count>0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.rankArray addObject:model];
            }
        }
        
        [self.classTable reloadData];
        
        
        [self requstDateRankData];
        
    } failure:^(NSInteger recode, NSError *error) {
        [self showHint:error.localizedDescription];
    }];
    
    /*
    [Utils get:nil parameters:param.mj_keyValues success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.rankArray removeAllObjects];
        
        if (array.count>0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.rankArray addObject:model];
            }
        }
        
        [self.classTable reloadData];
        
        
        [self requstDateRankData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
        [self showHint:error.localizedDescription];
    }];
     */
    
}
- (void)requstDateRankData
{
    NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
    
    [paramDic setObject:[NSString stringWithFormat:@"%@",dataLabel.text] forKey:@"datetime"];
    [paramDic setObject:[NSString stringWithFormat:@"%lld",schoolManage] forKey:@"scid"];
    [paramDic setObject:@"0" forKey:@"classid"];
    
    [Utils Java_get:@"api/getDailyRankList" parameters:paramDic success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.dataArray removeAllObjects];
        
        noDataLabel.hidden = YES;
        
        if (array.count > 0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.dataArray addObject:model];
            }

        }else {
            
            [self noDataLabel];
        }
        
        [self.classTable reloadData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
        [self showHint:error.localizedDescription];
    }];
    
    /*
    RequestParam *param = [[RequestParam alloc] init];
    param.method = @"api_face_rankingdate";
    param.scid = [NSString stringWithFormat:@"%lld",schoolManage];
    param.datetime = [NSString stringWithFormat:@"%@",dataLabel.text];
    param.pageno = @"1";
    param.pagesize = @"2000";
    
    [Utils get:nil parameters:param.mj_keyValues success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.dataArray removeAllObjects];
        
        noDataLabel.hidden = YES;
        
        if (array.count > 0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.dataArray addObject:model];
            }

        }else
        {
            
            [self noDataLabel];
        }
        
         [self.classTable reloadData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
        [self showHint:error.localizedDescription];
    }];
     */
}

- (void)requstMonthRankData {
    
    NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
    
    //todo [paramDic setObject:[NSString stringWithFormat:@"%lld",schoolManage] forKey:@"scid"];
    [paramDic setObject:[NSString stringWithFormat:@"%@-01",dataLabel.text] forKey:@"datetime"];
    [paramDic setObject:@"0" forKey:@"classid"];
    [paramDic setObject:[SYAccountTool ShareAccount].account.scid forKey:@"scid"];
    
    [Utils Java_get:@"api/getMonthAvgTimeTop" parameters:paramDic success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.dataArray removeAllObjects];
        
        noDataLabel.hidden = YES;
        
        if (array.count > 0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.dataArray addObject:model];
            }
            
            
        }else
        {
            [self noDataLabel];
        }
        
        [self.classTable reloadData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
        [self showHint:error.localizedDescription];
    }];
    
    /*
    RequestParam *param = [[RequestParam alloc] init];
    param.method = @"api_face_rankingmonth";
    param.scid = [NSString stringWithFormat:@"%lld",schoolManage];
    param.datetime = [NSString stringWithFormat:@"%@-01",dataLabel.text];
    param.pageno = @"1";
    param.pagesize = @"2000";
    
    [Utils get:nil parameters:param.mj_keyValues success:^(NSInteger recode, id jsonObject) {
        
        NSArray *array = [jsonObject objectForKey:@"re_data"];
        
        NSLog(@"array = %@%@",array,jsonObject);
        
        [self.dataArray removeAllObjects];
        
        noDataLabel.hidden = YES;
        
        if (array.count > 0) {
            
            for (NSDictionary * dic in array) {
                
                RankModel * model = [RankModel mj_objectWithKeyValues:dic];
                [self.dataArray addObject:model];
            }
            
           
        }else
        {
            [self noDataLabel];
        }
        
         [self.classTable reloadData];
        
    } failure:^(NSInteger recode, NSError *error) {
        
        [self showHint:error.localizedDescription];
    }];
     */
}

- (NSString *)getCurrentMonthString
{
    NSCalendar *calender = [NSCalendar currentCalendar];//获取NSCalender单例。
    NSDateComponents *cmp = [calender components:(NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:[NSDate date]]; //设置属性，因为我只需要年和月，这个属性还可以支持时，分，秒。
    NSDate *currentMonDate = [calender dateFromComponents:cmp];
    
    NSDateFormatter* formater = [[NSDateFormatter alloc] init];
    
    [formater setDateFormat:@"YYYY-MM"];
    
    NSString *month = [formater stringFromDate:currentMonDate];
    
    return month;
    
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)noDataLabel
{
    noDataLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, (SCREENHEIGH + 252)/2, SCREENWIDTH, 15)];
    noDataLabel.text = @"暂无统计";
    noDataLabel.font = [UIFont systemFontOfSize:15];
    noDataLabel.textColor = RGBCOLOR(151, 151, 151);
    noDataLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:noDataLabel];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
